{template 'common/header'}
<title>{$goods['title']}</title>
<style type="text/css">
body {margin:0px; background:#eee; -moz-appearance:none; -webkit-appearance: none;}
ul,li {padding:0px; margin:0px;}
.clear_in{overflow: hidden;zoom: 1;}
a{ text-decoration:none;}
.fl{float:left;}
.fr{float:right;}

i.do{background:url("../addons/sz_yi/template/mobile/inzens/new/images/icons.svg") no-repeat left top;display:inline-block; position:relative;float:none; margin:0; padding:0;}
i.do-man{ width:12px; height:12px; background-position:0 -185px; top:1px;}
i.do-low{ width:12px; height:12px; background-position:-21px -185px; top:1px;}
i.do-di{ width:12px; height:12px; background-position:-43px -185px; top:1px;}
i.do-kf{ width:22px; height:22px; background-position:-87px -181px; left:2px;}
i.do-cart_b{ width:23px; height:22px; background-position:-114px -180px;}
i.do-cart_t{ width:16px; height:16px; background-position:-88px -184px;}
i.do-gow{ width:12px; height:12px; background-position:-64px -185px; top:1px; margin-right:2px;}

.good_topbar { width:100%;position:fixed; top:0px; height:40px;z-index: 8;line-height:35px;}
.good_topbar .left { float:left; width:30px;height:30px;margin-left:0;margin-top:5px;}
.good_topbar .right { float:right; width:40px;height:30px;margin-left:0;margin-top:5px;}
.good_topbar .btn {width:30px;height:30px;margin-left:5px;border-radius:30px;float:left;background:#fff;color:#000;line-height:30px;text-align:center;filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5;}

.sort_list {height:90px; width:90px;padding:5px; background:rgba(64,69,72,0.9); border-radius:5px; display:none; position:absolute; top:40px; right:5%; z-index:999}
.sort_list .nav {height:30px; padding:0px 10px; border-bottom:1px solid #696d6f; color:#c6c7c8; line-height:30px; font-size:13px;}

.good_img {height:300px; width:100%; background:#f1f1f1;}
.good_img img {height:100%; width:100%;}
#notbuy{position:absolute; left:5px; bottom:10px;z-index:1; padding:3px 6px; border-radius:20px; background-color:#000;filter:alpha(opacity=70); -moz-opacity:0.7; opacity:0.7; line-height:10px;}
#notbuy span{ font-size:12px; color:#fff;}
#buytime{position:absolute; left:5px; bottom:10px;z-index:1;padding:3px 6px; border-radius:20px; background-color:#000;filter:alpha(opacity=70); -moz-opacity:0.7; opacity:0.7; line-height:10px;}
#buytime span{ font-size:12px; color:#fff;}
.good_img{overflow:hidden;position:relative;width:100%;}
.main_image{width:100%;position:relative;top:0;left:0;width:100%;}
.main_image ul{;position:absolute;top:0;left:0;width:100%;}
.main_image li{float:left;width:100%;}
.main_image li img{width:100%;}
.main_image li a{display:block;width:100%;}
.timestate span {color:#fff;font-size:12px;}

.good_info1 {height:auto; width:100%; background:#fff;}
.good_info1 .info1 {height:38px; width:97%; padding:3% 0 3% 3%; background-color:#f7f7f7;}
.good_info1 .info1 .name {height:38px; width:75%; float:left; font-size:14px;color:#333; line-height:18px; overflow:hidden;}
.good_info1 .info1 .love{ height:38px; width:20%; float:right; text-align:center; color:#999; border-left:1px solid #e3e3e3; font-size:12px; line-height:20px;}
.good_info1 .info1 .love i {height:16px; width:16px; margin-right:2px;color:#999; line-height:18px; font-size:14px;}
.good_info1 .info2  {height:36px; width:97%; padding:3% 0 2% 3%; color:#333; font-size:16px;}
.good_info1 .price {height:50px; width:94%; margin:0 3%; font-size:14px; color:#ff6700; line-height:20px; padding-top:10px; background-color:#fff;}
.good_info1 .price span {font-size:12px; color:#999;}
.good_info1 .price span.cx {font-size:12px; padding:3px; background-color:#ff6700; color:#fff; position:relative; left:0; bottom:4px; border-radius:5px; margin-right:5px}
.good_info1 .price span.sale{ margin-left:8px;}
.good_info1 .price #marketprice{ font-size:28px;color:#ff6700; position:relative; left:-6px; top:1px;}
.good_info1 .price #productprice{font-size:12px;text-decoration: line-through;}

.good_info1 .other { width:94%; margin:0px 3%;border-top:1px solid #f3f3f3; height:34px; line-height:34px; font-size:12px; color:#999;}
.good_info1 .other1 {margin-right:30px;} 
.good_info1 .other .left { float:left; text-align:right;}
.good_info1 .other .right { float:right; text-align:right;}

.deal_recom{width:97%; overflow: hidden; background:#fff; padding:3% 3% 0 0;color:#333; font-size:13px;}
.deal{ width:30.2%; height:130px; margin-left:3%; margin-bottom:3%;}
.deal a{ width:100%; height:100%; display:block; overflow:hidden; text-align:center;}
.deal img{ height:96px; width:100%; margin-bottom:4px;}
.deal .name{height:16px; width:100%; font-size:12px; line-height:16px; color:#666; overflow:hidden;}
.deal .price {height:16px; width:100%; color:#ff6700; font-size:13px;}
.deal .price span {color:#aaa; font-size:12px; text-decoration:line-through;}

.good_speci {height:44px; width:94%; overflow: hidden; background:#fff; padding:0px 3%; margin-top:14px; line-height:44px; color:#333; font-size:13px; border-bottom:1px solid #e4e4e4;}
.good_speci1 {height:44px; width:94%; overflow: hidden; background:#fff; padding:0px 3%; margin-top:14px; line-height:44px; color:#333; font-size:13px;}
.store {height:65px;  background:#fff; padding:5px;}
.store .info .ico { float:left;  height:50px; width:30px; line-height:30px; font-size:16px; text-align:center; color:#666}
.store .info .info1 {height:54px; width:100%; float:left;margin-left:-30px;margin-right:-60px;}
.store .info .info1 .inner { margin-left:30px;margin-right:60px;overflow:hidden;}
.store .info .info1 .inner .user {height:25px; width:100%; font-size:14px; color:#333; line-height:25px;overflow:hidden;}
.store .info .info1 .inner .tel {height:20px; width:100%; font-size:13px; color:#999; line-height:20px;overflow:hidden;}
.store .info .info1 .inner .address {height:20px; width:100%; font-size:13px; color:#999; line-height:20px;overflow:hidden;}
.store .info .ico2 {height:50px; width:30px;padding-top:15px; float:right; font-size:24px; text-align:center; color:#666;}
.store .info .ico3 {height:50px; width:30px;padding-top:15px; float:right; font-size:24px; text-align:center; color:#666;} 
.store_more {height:20px;  background:#fff; font-size:14px; color:#999; line-height:20px; padding:5px; text-align: center;}

.good_shop {height:50px; width:94%; background:#fff; padding:3%; margin-top:14px;}
.good_shop .shop1 {height:50px; width:70%;}
.good_shop .shop1 img {height:50px; width:50px; margin-right:6px; float:left; overflow:hidden;}
.good_shop .shop1 .shop_info {height:50px; width:auto; float:left; font-size:14px; color:#333; line-height:25px;}
.good_shop .shop1 .shop_info span {font-size:13px; color:#666;}
.good_shop .shop2 {height:50px; width:24%; margin-right:3%;}
.good_shop .shop2 .sub1 {height:30px; width:100%; background-color:#ff6700; border-radius:5px; line-height:30px;text-align:center;font-size:13px; color:#fff; margin-top:10px;}
.good_shop1 { width:100%; background:#fff;}
.good_shop1 .shop_deta {height:30px; width:94%; overflow: hidden; background:#fff; margin:0px 3%; line-height:30px; color:#ff6700; font-size:12px; border-top:1px solid #e3e3e3;}
.good_shop1 .shop_deta span{ margin-right:10px;}

.good_info2 {height:auto; width:100%; background:#fff; margin-top:14px; }
.good_info2 .menu {height:40px; width:100%;}
.good_info2 .menu .nav {height:37px; width:25%;  float:left; font-size:14px; color:#333; text-align:center; line-height:37px; border-bottom:1px solid #dadada;}
.good_info2 .menu .navon {color:#ff6700; height:37px; line-height:37px; border-bottom:2px solid #ff6700; }
.good_info2 .tab_con {height:auto; width:100%; overflow: hidden;}
.good_info2 .tab_con .con {height:auto; display:none;color:#333;word-break:break-all;}
.good_info2 .tab_con .con p{ font-size:14px;}
.good_info2 .tab_con .con_x {height:auto; width:94%; margin:10px 3%; display:none;color:#333;word-break:break-all;}
.good_info2 .tab_con .param { padding:8px; border-bottom:1px solid #dadada; font-size:13px; color:#666}
.good_info2 .tab_con #con_1 img { width:100%;outline-width:0px;  vertical-align:top; display:block}

.good_bottom {height:50px; width:100%; background:#ff6801; position:fixed; bottom:0px; left:0px;}
.good_bottom span {font-size:14px; line-height:10px;}
.good_bottom .buy {height:50px; width:35%; background:#ff6801; float:left; font-size:16px; line-height:50px; text-align:center; color:#fff;}
.good_bottom .add {height:50px; width:35%; background:#fd9a34; float:left; font-size:16px; line-height:50px; text-align:center; color:#fff;}
.good_bottom .cart {height:42px; width:15%; background:#fdfdfd; float:left; padding-top:7px; border-top:1px solid #e1e1e1; text-align:center; font-size:20px; color:#666;line-height:10px; position:relative;}
.good_bottom .cart b {height:16px; width:16px; background:#f30; border-radius:8px; position:absolute; top:2px; right:5px; font-size:12px; color:#fff; line-height:16px; font-weight:100;}
.good_bottom .like {height:42px; width:14%; background:#fdfdfd; float:left; padding-top:7px; border-top:1px solid #e1e1e1; border-right:1px solid #e1e1e1; text-align:center; font-size:20px; color:#666; line-height:10px;}
.good_bottom .like a{ color:#666;}

.good_copyright {font-size:14px; line-height:14px; padding:0 0 10px 0; text-align:center; color:#aaa; background-color:#fff; padding-bottom:60px;}

.comment { padding:5px; border-bottom:1px solid #ccc;overflow:hidden;}
.comment .info { padding:5px;height:35px;width:100%;}
.comment .info .head { float:left; width:30px;height:30px;}
.comment .info .head img { width:100%;height:100%; }
.comment .info .nickname { float:left;width:100%;margin-left:-30px;margin-right:-100px;height:30px;line-height:30px;overflow:hidden;}
.comment .info .nickname .inner { margin-left:35px;margin-right:100px;overflow:hidden; }
.comment .info .level { width:100px;float:right; margin-right:3%; text-align:right;height:30px;line-height:30px;color:#ff6600}
.comment .info .level i {width:13px;}

.comment .content { overflow:hidden;color:#555;font-size:13px;padding-left:5px;}
.comment .time { padding:5px; color:#666;font-size:13px;padding-left:5px;}
.comment .imgs { overflow:hidden;padding-top:5px;padding-left:5px;}
.comment .imgs img { padding:1px;border:1px solid #ccc;float:left;margin-right:5px;}
#comment_loading { width:94%;padding:10px;color:#888;text-align: center; font-size:12px;} 
#recommand_container  {height:auto; width:100%; background:#fff; overflow:hidden;float:left;} 
#recommand_container .good {height:auto; width:46%; padding:0px 2% 10px; float:left;}
#recommand_container .good img {height:120px; width:100%;}
#recommand_container .good .name {height:20px; width:100%; font-size:13px; line-height:20px; color:#666; overflow:hidden;}
#recommand_container .good .price {height:20px; width:100%; color:#ff6700; font-size:14px;}
#recommand_container .good .price span {color:#aaa; font-size:12px; text-decoration:line-through;}

</style>
<div id='container'></div>
<div id='cover'><img src='../addons/sz_yi/static/images/guide.png' style='width:100%;' /></div>

<script id='goods_info'  type='text/html'>
    <input type="hidden" id="followed" value="<%followed%>" />
    <input type="hidden" id="needfollow" value="<%goods.needfollow%>" />
    <input type="hidden" id="followurl" value="<%followurl%>" />
    <input type='hidden' id='followtip' value='<%followtip%>'/>
    <div class="good_topbar">
        <div class="left">
            <div class="btn back" onclick="history.back();"><i class="fa fa-chevron-left"></i></div>
        </div>
        <div class="right">
            <div class="btn func" onclick="menu(this)" ><i class="fa fa-ellipsis-v"></i></div>
        </div>
         <div class="sort_list">
                <div class="nav" onclick="location.href='<%shop.url%>'"><i class='fa fa-home'></i> 首页</div>
                <div class="nav" onclick="location.href='{php echo $this->createMobileUrl('member')}'"><i class='fa fa-user'></i> 会员中心</div>
                <div class="nav" onclick="share()" style="border:none;"><i class='fa fa-share'></i> 分享</div>
          </div>
    </div>
	
	<div class="good_choose_layer"></div>
    <div class="good_choose">
        <div class="info">
             <div class="left">

                 <img id="chooser_img" src="<%goods.thumb%>"/>
             </div>
             <div class="right">
                   <div class="price">￥<span id='option_price'><%goods.marketprice%></span></div>
                   <div class="option">请选择规格</div>
             </div>
            <div class="close" onClick="closechoose()"><i class="fa fa-remove-o"></i></div>
        </div>
        <div class="other">
            <input type='hidden' id='optionid' value='' />
                <%each specs as spec%>
                <input type='hidden' name="optionid[]" class='optionid optionid_<%spec.id%>' value="" title="<%spec.title%>">
                <div class="spec"><%spec.title%></div>
                <div class="spec_items options_<%spec.id%>"  title="<%spec.title%>">
                      <%each spec.items as o%>
                      <div class="option option_<%spec.id%>" specid='<%spec.id%>' oid="<%o.id%>" sel='false' title='<%o.title%>' thumb='<%o.thumb%>'><%o.title%></div>
                     <%/each%>
                </div>
                <%/each%>

                <div class='number'> 
                    <div class='label'>购买数量</div>
                  <div class='num'>
                            <button id='btn_minus' onclick='reduceNum()'><i class='fa fa-minus'></i></button>
                            <input type='text' id='total' value='1' />
                            <button id='btn_plus' onclick='addNum()'><i class='fa fa-plus'></i></button>
                  </div>
                    
                </div>
        </div>
        <div class="close" onClick="closechoose()"><i class="fa fa-times-circle-o"></i></div>
        <div class="sub " onClick="choose2()">确认</div>
    </div>
	
	<div class="good_img">
        <%if pics.length>1%>
        <div class="flicking_con">
            <div class="inner">
				<div id="buytime" style="display:none"></div>
            	<div id="notbuy" style="display:none"></div>
            </div>
        </div>
        <%/if%>
        <div class="main_image">
            <ul>
                <%each pics as p %>
                <li><img src="<%p%>"></li>
                <%/each%>
            </ul>
        </div>
    </div>
	
	<div class="good_info1">
		<%if commission && goods.nocommission==0 && goods.hidecommission==0%>
		<div class="info1">
			<div class="name"><%goods.title%></div>
			<div class="love">
				<i class="fa <%if isfavorite%>fa-star<%else%>fa-star-o<%/if%>" <%if isfavorite==1%>style="color:#f90"<%/if%>></i>
				<br><span>喜欢</span>
			</div>
		</div>
		<%else%>
		<div class="info2"><%goods.title%></div>
		<%/if%>
		
		<div class="price">￥<span id='marketprice'>
			<%if goods.minprice !=goods.maxprice%>
			<%goods.minprice%> - <%goods.maxprice%>
			<%else%>
			<%goods.marketprice%>
			<%/if%>
			</span><span class="cx">今日促销</span><%if goods.issendfree==1%><span class='cx'>包邮</span><%/if%><br>
			<span id='productpricecontainer'><%if goods.productprice>0%>原价￥<%/if%><span id='productprice'><%if goods.productprice>0%><%goods.productprice%><%/if%></span></span>
			<span class="sale">已售:<%goods.sales%>件</span>
		</div>
	
		<%if saleset && saleset.enoughfree=='1' %>
		<div class="other">
			<%if saleset.enoughorder<=0%>
			<span><i class='do do-man'></i>全场包邮</span>
			<%else%>  
			<span><i class='do do-man'></i>满<%saleset.enoughorder%>元包邮</span>
			<%/if%>
			
			<%if saleset && saleset.enoughmoney>0 && saleset.enoughdeduct >0 %>
			<span><i class='do do-low'></i>满<%saleset.enoughmoney%>元减<%saleset.enoughdeduct%>元</span>
			<%/if%> 
		</div>
		<%/if%> 
	
		<%if goods.deduct>0%>
		<div class="other">
			<div class='left'>
				<span><i class='do do-di'></i> 可使用积分抵扣<span style='color:#ff6600'><%goods.deduct%></span> 元</span>
			</div>
		</div>
		<%/if%> 
	
		<%if goods.isnodiscount=='0' && level.discount>0 && level.discount<10%>
		<div class="other">
			<div class='left'>
				<i class='fa fa-user'></i>您是<%level.levelname%>,可享<span style='color:#ff6600'><%level.discount%></span> 折优惠
			</div>
		</div> 
		<%/if%>
	</div>

	
	<%if goods.isverify=='2'%>
	<div class="good_speci" onclick="showStores(this)" show="1">适用的门店
		<i class="fa fa-angle-down" style="float:right; line-height:44px; font-size:26px;"></i>
	</div>
	<div>
		<%each stores as store index%>
		<%if index<=1%>
		<div class="store" >
			<div class="info">
				<div class="ico"><i class="fa fa-building-o"></i></div>
				<div class='info1'>
					<div class='inner'>
						<div class="user"><%store.storename%></div>
						<div class="address">地址: <%store.address%></div>
						<div class="tel">电话: <%store.tel%></div>
					</div>
				</div>
			<a href="http://api.map.baidu.com/marker?location=<%store.lat%>,<%store.lng%>&title=<%store.storename%>&name=<%store.storename%>&content=<%store.address%>&output=html"><div class="ico2"><i class='fa fa-map-marker'></i></div></a>
			<a href="tel:<%store.tel%>"><div class="ico3" ><i class='fa fa-phone'></i></div></a>
			</div>
		</div>
		<%/if%>
		<%/each%> 
		
		<div id='store_more' style="display:none">
			<%each stores as store index%>
			<%if index>1%>
			<div class="store" >
				<div class="info">
					<div class="ico"><i class="fa fa-building-o"></i></div>
					<div class='info1'>
					<div class='inner'>
						<div class="user"><%store.storename%></div>
						<div class="address">地址: <%store.address%></div>
						<div class="tel">电话: <%store.tel%></div>
					</div>
				</div>
				<a href="http://api.map.baidu.com/marker?location=<%store.lat%>,<%store.lng%>&title=<%store.storename%>&name=<%store.storename%>&content=<%store.address%>&output=html"><div class="ico2"><i class='fa fa-map-marker'></i></div></a>
				<a href="tel:<%store.tel%>"><div class="ico3" ><i class='fa fa-phone'></i></div></a>
				</div>
			</div>
			<%/if%>
			<%/each%> 
		</div>
		
		<%if stores.length>=3%>
		<div class="store_more" onclick="$('#store_more').show();$(this).remove()">显示更多 <i class="fa fa-angle-double-down"></i></div>
		<%/if%>
	</div>
	<%/if%>
	
	<%if goods.canbuy && goods.total!=0 && goods.timebuy=='0' && goods.userbuy=='1'  && goods.groupbuy=='1'  && goods.levelbuy=='1'%> 
		<div class="good_speci1" onClick="choose()">
			<span id="optiondiv">请选择商品规格及数量</span>
			<i class="fa fa-angle-right" style="float:right; line-height:44px; font-size:26px;"></i>
		</div>
	<%/if%>
	
	<div class="good_shop clear_in">
		<div class="shop1 fl" onClick="location.href='<%detail.btnurl2%>'">
			<img src="<%shop.logo%>">
			<div class="shop_info"><%shop.name%><br><span>官方推荐合作商家</span></div>
		</div>
		<div class="shop2 fr"><div class="sub1" onClick="location.href='{php echo $this->createPluginMobileUrl('commission/shares',array('goodsid'=>$_GPC['id']))}'"><%commission_text%></div></div>
	</div>
	<div class="good_shop1">
		<div class="shop_deta">
			<span><i class="do do-gow"></i>正品保障</span><span><i class="do do-gow"></i>金牌服务</span><span><i class="do do-gow"></i>专业配送</span><span><i class="do do-gow"></i>无忧售后</span>
		</div>
	</div>
	
	<div class="good_info2">
        <div class="menu">
            <div id="nav_1" class="nav navon" onClick="tab(1)">图文详情</div>
            <div id="nav_2" class="nav" onClick="tab(2)">产品参数</div>
            <div id="nav_3" class="nav" onClick="tab(3)">用户评价</div>
            <div id="nav_4" class="nav" onClick="tab(4)" style="border-right:0px; width:24%">同店推荐</div>
        </div>
        <div class="tab_con">
            <div class="con" id="con_1"  style='display:block'><%=goods.content%></div>
            <div class="con_x" id="con_2">
                <%if params.length<=0%>
                 无任何产品参数
                <%/if%>
                <%each params as value%>
                <p class='param'><%value.title%>: <%value.value%> </p>
                <%/each%>
            </div>
            <div class="con_x" id="con_3" ><div id='comment_container'></div></div>
            <div class="con_x" id="con_4"><div id='recommand_container'></div></div>
        </div>
    </div>
	
	{php $shopset = m('common')->getSysset('shop')}
    <div class="good_copyright">© 版权所有 {if !empty($shopset['name'])}{$shopset['name']}{else}{$_W['account']['name']}{/if}</div>

    <%if goods.canbuy && goods.total!=0 && goods.timebuy=='0' && goods.userbuy=='1' && goods.groupbuy=='1'  && goods.levelbuy=='1'%>
    <div class="good_bottom">
        <div class="like" >
            <a href="000000000000000">
				<i class="do do-kf"></i><br><span>客服</span>
			</a>
        </div>
         <%if goods.canaddcart%>
        <div class="cart" onclick="location.href='{php echo $this->createMobileUrl('shop/cart')}'"><i class="do do-cart_b"></i><br><span>购物车</span>
            <%if cartcount>0%><b><%cartcount%></b><%/if%>
        </div>
        <div class="add" onclick="choose('cart')">加入购物车</div>
        <%/if%>
        <div class="buy" onclick="choose('buy')" <%if !goods.canaddcart%>style='width:80%'<%/if%>>立即购买</div>
	</div>
    <%/if%>
</script>
<script id='tpl_comment' type='text/html'>
    <%each list as comment%>
    <div class='comment'>
                    <div class='info'>
                        <div class='head'><img src='<%comment.headimgurl%>' style='width:30px;height:30px;' /></div>
                        <div class='nickname'><div class='inner'><%comment.nickname%></div></div>
                        <div class='level'>
                            <%if comment.level>=1%><i class='fa fa-star'></i><%else%><i class='fa fa-star-o'></i><%/if%>
                            <%if comment.level>=2%><i class='fa fa-star'></i><%else%><i class='fa fa-star-o'></i><%/if%>
                            <%if comment.level>=3%><i class='fa fa-star'></i><%else%><i class='fa fa-star-o'></i><%/if%>
                            <%if comment.level>=4%><i class='fa fa-star'></i><%else%><i class='fa fa-star-o'></i><%/if%>
                            <%if comment.level>=5%><i class='fa fa-star'></i><%else%><i class='fa fa-star-o'></i><%/if%>
                            </div>
                    </div>
                    <div class='content'><%comment.content%></div>
                    <%if comment.images.length>0%>
                       <div class='imgs'>
                          <%each comment.images as img%><img src='<%img%>' style='width:30px;height:30px;' /><%/each%>
                    </div>
                    <%/if%>
                   <%if comment.reply_content!=''%>
                         <div class='content' style='margin-top:5px;'><span style='color:#ff6600'>[回复]</span><%comment.reply_content%></div>
                        <%if comment.reply_images.length>0%>
                            <div class='imgs'>
                               <%each comment.reply_images as img%><img src='<%img%>' style='width:30px;height:30px;' /><%/each%>
                         </div>
                   <%/if%>
                      <%/if%>
              
                     <%if comment.append_content!=''%>
                         <div class='content' style='margin-top:5px;'><span style='color:#ff6600'>[追加]</span><%comment.append_content%></div>
                        <%if comment.append_images.length>0%>
                            <div class='imgs'>
                               <%each comment.append_images as img%><img src='<%img%>' style='width:30px;height:30px;' /><%/each%>
                         </div>
                      <%/if%>
                     <%/if%>
                
                  <%if comment.append_reply_content!=''%>
                         <div class='content' style='margin-top:5px;'><span style='color:#ff6600'>[回复]</span><%comment.append_reply_content%></div>
                        <%if comment.append_reply_images.length>0%>
                            <div class='imgs'>
                               <%each comment.append_reply_images as img%><img src='<%img%>' style='width:30px;height:30px;' /><%/each%>
                         </div>
                      <%/if%>
                     <%/if%>
             <div class='time'><%comment.createtime%></div>
     </div>
     <%/each%>
</script>
<script id='tpl_recommand' type='text/html'>
     <%each list as g%>
    <div class="good" data-goodsid='<%g.id%>'>
        <img src="<%g.thumb%>">
        <div class="name"><%g.title%></div>
        <div class="price">￥<%g.marketprice%> <%if g.productprice>0 && g.marketprice!=g.productprice%><span>￥<%g.productprice%></span><%/if%></div>
    </div>
    <%/each%>
</script>
<script language="javascript">
    var hasoption = false;
    var maxbuy = 0;
    var options = [];
    var specs = [];
    var tip = null;
    var action="";
    var alpha = 0;
    
    function share(){
        
           $('#cover').fadeIn(200).unbind('click').click(function(){
                    $(this).fadeOut(100);
          })
    }
    function menu(obj){
       
        if($(obj).attr('show')=='1'){
            $(obj).removeAttr('show');
            $('.sort_list').fadeOut(200);
        }else{
            $(obj).attr('show','1');  
            $('.sort_list').fadeIn(200);
        }
    }
    $(function(){
        $(document.body).click(function(e){
           var classname = "";
           
            if($(e.target).get(0) ){
                classname =$(e.target).get(0).className;
            }
            if(classname!='fa fa-ellipsis-v' && classname!='btn func') {
                
                $('.func').removeAttr('show');
                $('.sort_list').fadeOut(200);
            }
        });
    })
    function showStores(obj){
        if($(obj).attr('show')=='1'){
            $(obj).next('div').slideUp(100);
            $(obj).removeAttr('show').find('i').removeClass('fa-angle-down').addClass('fa-angle-up');
        }
        else{
            $(obj).next('div').slideDown(100);
            $(obj).attr('show','1').find('i').removeClass('fa-angle-up').addClass('fa-angle-down');
        }
    }
    require(['tpl', 'core','jquery.touchslider','swipe'], function(tpl, core) {
      function setTimer(goods){
            
            setTimeHtml(goods);
            window.timer = setInterval(function(){
                setTimeHtml(goods);
            },1000);
        }
        function setTimeHtml(goods){
            var current = Math.floor(new Date().getTime()/1000);
                var ts = 0;//计算剩余的毫秒数
                var prefix = '';
                
                if(goods.timestate=='before'){
                    ts = goods.timestart - current;
                    prefix = "限时购开始倒计时: ";
                    if(ts<=0){
                        location.reload();
                    }
                }
                else if(goods.timestate=='after'){
                    ts = goods.timeend - current;
                    
                    prefix = "限时购结束倒计时:  ";
                     if(ts<=0){
                        location.reload();
                    }
                }
                var dd = parseInt(ts / 60 / 60 / 24, 10);//计算剩余的天数
                var hh = parseInt(ts  / 60 / 60 % 24, 10);//计算剩余的小时数
                var mm = parseInt(ts  / 60 % 60, 10);//计算剩余的分钟数
                var ss = parseInt(ts % 60, 10);//计算剩余的秒数
                dd = checkTime(dd);
                hh = checkTime(hh);
                mm = checkTime(mm);
                ss = checkTime(ss);
                $('.timestate').html(prefix+ "<span>" + dd + "</span>天<span>" + hh + "</span>时<span>" + mm + "</span>分<span>" + ss + "</span>秒");
        }
        function checkTime(i)    
            {    
               if (i < 10) {    
                   i = "0" + i;    
                }    
               return i;    
            } 

        core.json('shop/detail',{id:'{$_GPC['id']}',mid:"{$mid}"},function(json){
     
          tip = core.tip;
          if(json.status<=0){
              core.message('没有找到您想要的宝贝哦~',"{php echo $this->createMobileUrl('shop/list')}",'error');
              return;
          }
            
        $(window).scroll(function(){
         
           var top = $(document).scrollTop() ;
           alpha = top/270 ;
           if(alpha>0.5){
               alpha = 0.5;
           }
           $('.good_topbar').css("background","rgba(237,237,237,"+ alpha + ")");
             $('.good_topbar .btn').css("background","rgba(237,237,237,"+ (0.5-alpha) + ")");
        });
         $('body').on("touchmove",function(){
                
           var top = $(document).scrollTop() ;
           alpha = top/270 ;
           if(alpha>0.6){
               alpha = 0.6;
           }
          $('.good_topbar').css("background","rgba(237,237,237,"+ alpha + ")");
          $('.good_topbar .btn').css("background","rgba(237,237,237,"+ (0.6-alpha) + ")");
        });
        
          $('#container').html(  tpl('goods_info',json.result) ); 
    
          var bh = $(document.body).height() - 50;
          $('.good_choose').css('max-height',bh); 
          $('.good_choose .other').css('max-height',bh-175);
       
         // alert(document.body.clientWidth);
         $('.good_img').height( document.body.clientWidth + "px");
              
          $('#con_1 img,#con_1 table,#con_1 div').width('100%');
           var ua = navigator.userAgent.toLowerCase();
           var isWX = ua.match(/MicroMessenger/i) == "micromessenger";
           var z = []; 
           $(".main_image img").each(function() {
                z.push($(this).attr("src"));
            });
            var current;
            if (isWX) {
                $(".main_image img").click(function(e) {
                    e.preventDefault();
                    var startingIndex = $(".main_image img").index($(e.currentTarget));
                    var current = null;
                    $(".main_image img").each(function(B, A) {
                        if (B === startingIndex) {
                            current = $(A).attr("src");
                        }
                    });
                    WeixinJSBridge.invoke("imagePreview", {
                        current: current,
                        urls: z
                    });
                });
            }
            
              var z1 = []; 
           $("#con_1 img").each(function() {
                z1.push($(this).attr("src"));
            });
            var current1;
            if (isWX) {
                $("#con_1 img").click(function(e) {
                    e.preventDefault();
                    var startingIndex = $("#con_1 img").index($(e.currentTarget));
                    var current = null;
                    $("#con_1 img").each(function(B, A) {
                        if (B === startingIndex) {
                            current1 = $(A).attr("src");
                        }
                    });
               
                    WeixinJSBridge.invoke("imagePreview", {
                        current: current1,
                        urls: z1
                    });
                });
            }
            
      
            
           document.title = json.result.goods.title;
           hasoption = json.result.options.length>0;
           goods = json.result.goods;
           maxbuy = json.result.goods.maxbuy;
           options = json.result.options;
           specs = json.result.specs;
           
           nothtml = "";
           timehtml = "";
           hastime = false;
            if( goods.canbuy){
                     if(goods.userbuy=='0') {
                               nothtml = "您已超出购买上限~";
                     } else {
                              if( goods.groupbuy=='0' || goods.levelbuy=='0'){
                                         nothtml="您不能购买此商品,请联系客服";
                             } else {
                                        if( goods.total==0){
                                                 nothtml="库存不足，无法购买";
                                        } else {
                                                 if( goods.istime=='1'){
                                                      if( goods.timebuy=='1'){
                                                          nothtml= "限时购活动已经结束，请下次再来~"
                                                      }else{//未开始倒计时或进行中
                                                          nothtml='<span class="timestate"></span>';
                                                          hastime = true;
                                                      }
                                                 }
                                        }
                             }

                    }
                     if( goods.istime=='1'){
                                                      if( goods.timebuy!='1'){
                                                         
                                                          timehtml = '<span class="timestate"></span>';
                                                      }
                                                 }
                     
        }else{
            nothtml = "商品已下架";
        }
        if( nothtml!=''){
            $('#notbuy').html(nothtml).show();
        }
        if( timehtml!='' && !hastime){
            $('#buytime').html(timehtml).show();
        }
        if($('.timestate').length>0) {
               if(goods.timestate!=''){
                     setTimer(goods);
               }
        }
            
           
           if(options.length>0){
             $('#productpricecontainer').html('');
           }
   
           $('#total').blur(function(){
              var total = $("#total");
	if(!total.isInt()){
	     total.val("1");
                       return;
	}
                  if(parseInt(total.val())<=0){
	     total.val("1");
                       return;
	} 
	var stock = $("#stock").html()==''?-1:parseInt($("#stock").html());
	var num = parseInt(total.val() );
                  if(num>maxbuy && maxbuy>0){
		tip.show("您最多可购买 " + maxbuy + " 件!");
		num = maxbuy;
	}
	else if(num>stock && stock!=-1){
		tip.show("您最多可购买 " + stock + " 件");
		num = stock;
	}
	
	total.val(num);
        
               
           });
 
               
                    new Swipe($('.main_image')[0], {
			speed:300,
			auto:4000,
			callback: function(){
			  
                                 $(".flicking_con  .inner  a").removeClass("on").eq(this.index).addClass("on");
		}
	  });
     
 
            $(".option").click(function() {
               
			 var specid = $(this).attr("specid");
			 var oid = $(this).attr("oid");
			$(".optionid_"+specid).val(oid);
			$(".options_" + specid + "  .option").removeClass("on").attr("sel", "false");
			$(this).addClass("on").attr("sel", "true");
	 
             var titles='已选: ';
			     $('.spec_items').each(function(){
                                 if($(this).find('.on').length>0){
			        titles+= $(this).find('.on').attr('title')+";";   
                            }
			     });
                             
                             $('.good_choose .info .right .option').html(titles);
         var thumb = $(this).attr('thumb');
         if(thumb!=''){
             $("#chooser_img").attr('src',thumb);
         }
         else{
             
             $("#chooser_img").attr('src',json.result.goods.thumb);
         }
         setoptions();
			var optionid = "";
			var stock =0;
			var marketprice = 0;
			var productprice = 0;
			 var ret = option_selected();
  
			if(ret.no==''){
				var len = options.length;
				for(var i=0;i<len;i++) {
					var o = options[i];
					var ids = ret.all.join("_");
                                
                                var specarr = o.specs.split('_').sort();
                                var idsarr = ret.all.sort();
                              
                                
                                
                             
					if(specarr.join('_') ==idsarr.join('_') ){
						optionid = o.id;
						stock = o.stock;
						marketprice = o.marketprice;
						productprice = o.productprice;
						break;
					}
					
				}
                                
			   $("#optionid").val(optionid); 
			    
				if(stock!="-1"){
					$("#stockcontainer").html("库存:<span id='stock'>" + stock + "</span>");
				}
				else{
				  $("#stockcontainer").html("<span id='stock'></span>");
				}
				if(ret.no==''){
					if(stock==0){
					   $('.sub').addClass('disabled').html('库存不足,无法购买');
					}
					else{
					 $('.sub').removeClass('disabled').html('确认');
					}
				} 
				$("#marketprice").html(marketprice);
				
		     	$("#option_price").html(marketprice);	
		     	$("#option_stock").html(stock);	
				 
				$("#productprice").html(productprice);
				if(productprice<=0){
				$('#productpricecontainer').html("");
				}
				else{
			
				   $('#productpricecontainer').html("市场价￥<span id='productprice'>" + productprice + "</span>");
				}
			}
		});
                
           
                $('.love').click(function(){
                    var self = $(this);
                    require(['core'],function(core){
                       core.json('shop/favorite',{op:'set', id:'{$_GPC['id']}'},function(ret){
                           if(ret.status==1){
                
                                if(ret.result.isfavorite){
                                   self.find('i').removeClass('fa-star-o').addClass('fa-star').css('color','#f90');
                                }
                                else{
                                   self.find('i').addClass('fa-star-o').removeClass('fa-star').css('color','#999');
                                }
                           }
                           else{
                               core.tip.show('操作失败');
                           }
                       });
                      },false,true);
                });
                var page = 1;
          function bindCommentImages(){
                var z = []; 
                          $(".comment .imgs img").each(function() {
                             z.push($(this).attr("src"));
                         });
                         var current;
                         if (isWX) {
                             $(".comment .imgs  img").click(function(e) {
                                 e.preventDefault();
                                 var startingIndex = $(".comment .imgs  img").index($(e.currentTarget));
                                 var current = null;
                                 $(".comment .imgs  img").each(function(B, A) {
                                     if (B === startingIndex) {
                                         current = $(A).attr("src");
                                     }
                                 });
                                 WeixinJSBridge.invoke("imagePreview", {
                                     current: current,
                                     urls: z
                                 });
                             });
                         }
          }
                $('#nav_3').click(function(){
                    page = 1;
                     core.json('shop/util',{op:'comment', page:page,goodsid:'{$_GPC['id']}'},function(json){
                         if(json.result.list.length<=0){
                             $('#comment_container').html('暂时没有任何评价');
                             return;
                         }
                         $('#comment_container').html( tpl('tpl_comment',json.result));
                       bindCommentImages();
                            var loaded = false;
                              var stop=true; 
                              $(window).scroll(function(){ 
                                  if(loaded){
                                      return;
                                  }
                                    totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); 
                                    if($(document).height() <= totalheight){ 

                                        if(stop==true){ 
                                            stop=false; 
                                            $('#comment_container').append('<div id="comment_loading"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
                                            page++;
                                            core.json('shop/util', {op:'comment',page:page,goodsid:'{$_GPC['id']}'}, function(morejson) {  
                                                stop = true;
                                                $('#comment_loading').remove();
                                                $("#comment_container").append(tpl('tpl_comment', morejson.result));
                                                  bindCommentImages();
                                                if (morejson.result.list.length <morejson.result.pagesize) {

                                                    $("#comment_container").append('<div id="comment_loading">已经加载完全部评价</div>');
                                                    loaded = true;
                                                    $(window).scroll = null;
                                                    return;
                                                }
                                            },true); 
                                        } 
                                    } 
                                });
                     });
                 });
                 
                 $('#nav_4').click(function(){
                      core.json('shop/util',{op:'recommand'},function(json){
                         if(json.result.list.length<=0){
                             $('#recommand_container').html('暂时没有同店推荐');
                             return;
                         }
                         $('#recommand_container').html( tpl('tpl_recommand',json.result));
                         $('#recommand_container .good').click(function(){
                            location.href = core.getUrl('shop/detail',{id:$(this).data('goodsid') });
                         }).find('img').each(function(){
                             $(this).height($(this).width());
                         });
                         
                     });
                 });
        },true);
        
    })
</script>
<script type="text/javascript">
	function tab(n){
		$('#con_'+n).fadeIn();
		$('#con_'+n).siblings().hide();
		$('#nav_'+n).addClass('navon');
		$('#nav_'+n).siblings().removeClass('navon');
                      
	}
        function closechoose(){
                 $('.good_choose_layer').fadeOut(100);
		$('.good_choose').fadeOut(100); 
        }
	function choose(act){
            
                          if($('#followed').val()=='0'  && $('#needfollow').val()=='1' ){
                                require(['core'],function(core){
                                    core.tip.confirm($('#followtip').val(),function(){
                                        location.href = $('#followurl').val();
                                        return;
                                    }) 
                                });
                             return;
                          }
	        action = act;
                         if(!action){
                                     
                                $('.good_choose_layer').fadeIn(200);
                                          $('.good_choose_layer').unbind('click').click(function(){
                                                    $('.good_choose_layer').fadeOut(100);
                                 $('.good_choose').fadeOut(100); 
                                          })
                                $('.good_choose').fadeIn(200);
                                return;
                         }
						
                         var specselected  = '';
                 if( action=='cart'){
		    
			 $('.good_choose_layer').fadeIn(200);
							 $('.good_choose_layer').unbind('click').click(function(){
								   closechoose();
							 })
			   $('.good_choose').fadeIn(200);
			   return;	 
	         }else{
				 
				   $('.spec_items').each(function(){
							 var self = $(this);
				   if( $(this).find('.on').length<=0){
											 specselected = self.attr('title');
											 return false;
										   }
							});  
		     if(specselected!='') {
			   $('.good_choose_layer').fadeIn(200);
							 $('.good_choose_layer').unbind('click').click(function(){
								   closechoose();
							 })
			   $('.good_choose').fadeIn(200);
			   return;
		     }
			
		 }
                          if(action=='cart'){
                                                require(['core'],function(core){

                                                                           core.json('shop/cart',{op:'add', id:'{$_GPC['id']}',optionid:$('#optionid').val(),total:$('#total').val()},function(ret){
                                                                                                        if(ret.status==1){
                                                                                                           core.tip.show(ret.result.message);
                                                                                                           var cartdiv = $('.cart');
                                                                                                                               if( cartdiv.find('b').length<=0){
                                                                                                                                  cartdiv.append('<b>'+ ret.result.cartcount +"</b>");
                                                                                                                               }
                                                                                                                               else {
                                                                                                                                  cartdiv.find('b').html(ret.result.cartcount);
                                                                                                                               }

                                                                                                       } else{
                                                                                                           core.message(ret.result,'','error');
                                                                                                       }
                                                                               },true,true);
                                                 });
                                    }else if(action=='buy'){
                                         location.href = "{php echo $this->createMobileUrl('order/confirm')}&id={$_GPC['id']}&optionid=" +$("#optionid").val() + "&total=" + $("#total").val();
                                    }
 
	}
        function setoptions(){
             var titles = '';
   		         if(hasoption){
			     
			 titles+='已选: ';
			     $('.spec_items').each(function(){
 			        titles+= $(this).find('.on').attr('title')+";";   
			     });
		         }
                                             titles+='数量:' + $('#total').val();
		         $("#optiondiv").html(titles);
        }
	function choose2(direct,close){
            if(close){
                closechoose();
                return;
            }
	    if(!direct){
		    if($('.sub').hasClass('disabled')){
		       return;
		    }
		    else{
		        setoptions();
		    }
                                      
		  
	    } else {
                            action = "";
                      }
		
                var specselected  = '';
                
	    $('.spec_items').each(function(){
                
                   var self = $(this);
 		 if( $(this).find('.on').length<=0){
                                          specselected = self.attr('title');
                                          return false;
                                        }
                                });  
                                if( specselected!=''){
                                      require(['core'],function(core){
                                         core.tip.show('请选择' + specselected) ;
                                      });
                                      return;
                                }
                               
                             closechoose();
                              
		if(action=='cart'){
                                                require(['core'],function(core){

                                                                           core.json('shop/cart',{op:'add', id:'{$_GPC['id']}',optionid:$('#optionid').val(),total:$('#total').val()},function(ret){
                                                                                                        if(ret.status==1){
                                                                                                           core.tip.show(ret.result.message);
                                                                                                           var cartdiv = $('.cart');
                                                                                                                               if( cartdiv.find('b').length<=0){
                                                                                                                                  cartdiv.append('<b>'+ ret.result.cartcount +"</b>");
                                                                                                                               }
                                                                                                                               else {
                                                                                                                                  cartdiv.find('b').html(ret.result.cartcount);
                                                                                                                               }

                                                                                                       } else{
                                                                                                           core.message(ret.result,'','error');
                                                                                                       }
                                                                               },true,true);
                                                 });
                                    }else if(action=='buy'){
                                         location.href = "{php echo $this->createMobileUrl('order/confirm')}&id={$_GPC['id']}&optionid=" +$("#optionid").val() + "&total=" + $("#total").val();
                                    }

	}
  function addNum(){
	var total = $("#total");
	if(!total.isInt()){
		total.val("1");
	}
	var stock = $("#stock").html()==''?-1:parseInt($("#stock").html());
	var num = parseInt(total.val() ) + 1;
                  if(num>maxbuy && maxbuy>0){
		tip.show("您最多可购买 " + maxbuy + " 件!");
		num = maxbuy;
	}
	else if(num>stock && stock!=-1){
		tip.show("您最多可购买 " + stock + " 件");
		num = stock;
	}
	total.val(num);
}
function reduceNum(){
	var total = $("#total");
	if(!total.isInt()){
		total.val("1");
	}
	var num = parseInt( total.val() );
	if(num-1<=0){
		return;
	}
	num--;
	total.val(num);
}

	function option_selected(){
	var ret= {
		no: "",
		all: []
	};
	if(!hasoption){
		return ret;
	}
			$(".optionid").each(function(){
				ret.all.push($(this).val());
				if($(this).val()==''){
					ret.no = $(this).attr("title");
					return false;
				}
	})
	return ret;
}
</script>
{php $hide_footer=1}
{template 'common/footer1'}